import http from './http.js'
// export function getBillList(type,size=3,offset=0){
//     const url = `/api/v1/restserver/ting?method=baidu.ting.billboard.billList&type=${type}&size=${size}&offset=${offset}`
//     return http.get(url)
// }

//专题列表
export function getSubject() {
    const url = `/api/bbs/bbsCategory/open/list`
    return http.post(url)
}
// 帖子列表
export function getCard(categoryId){
    return http.post(`/api/bbs/bbsPosts/open/list?categoryId=${categoryId}`)
}
// 获取帖子详情
export function getCardInfo(postsId){
    return http.get(`/api/bbs/bbsPosts/open/detail/${postsId}`)
}
// 删除帖子
export function delCard(ids){
    const list = new FormData();
    list.append("ids",ids)
    return http.post("/api/bbs/bbsPosts/site/remove/",list)
}
// 修改帖子
export function rewriteCard(postsId,title){
    const list = new FormData();
    list.append("postsId",postsId)
    list.append("title",title)
    return http.post("/api/bbs/bbsPosts/site/edit/",list)
}
// 查看全部评论
export function discussAll(postsId){
    const list = new FormData();
    list.append('postsId',postsId) 
    return http.post(`/api/bbs/bbsComment/open/list?postsId=${postsId}`)
}
// 发表言论
export function site(postsId,commentContent){
    const list = new FormData();
    list.append('postsId',postsId),
    list.append('commentContent',commentContent)
    return http.post(`/api/bbs/bbsComment/site/add`,list)
}
// 回复言论
export function issueDiscuss(postsId,parentId,commentContent){
    const list = new FormData();
    list.append('postsId',postsId)
    list.append('parentId',parentId)
    list.append('commentContent',commentContent)
    return http.post(`/api/bbs/bbsComment/site/reply/add`,list)
}
// 回复列表
export function replayList(parentId){
    const list = new FormData();
    list.append('parentId',parentId)
    return http.post(`/api/bbs/bbsComment/open/reply/list`,list)
}
//创建帖子
export function addList(categoryId,title,intro,coverImgUrl){
    const list = new FormData();
    list.append("categoryId",categoryId);
    list.append("title",title);
    list.append("intro",intro);
    list.append("coverImgUrl",coverImgUrl);
    return http.post("/api/bbs/bbsPosts/site/add",list)
}


//注册
export function registry(loginName,phonenumber,email,password,userName,code){
    const registied = new FormData();
    registied.append("loginName",loginName);
    registied.append("phonenumber",phonenumber);
    registied.append("email",email);
    registied.append("password",password);
    registied.append("userName",userName);
    registied.append("code",code);
    return http.post("/api/registry",registied)
}
//验证码
export function code(mobile) {
    return http.get(`/api/short-message/vcode/${mobile}`)
}

//登陆
export function login(username, password, rememberMe = false) {
    const login = new FormData();
    login.append("username", username);
    login.append("password", password);
    login.append("rememberMe", rememberMe);
    return http.post("/api/login", login)
}
//忘记密码
export function forget(loginName, password, phonenumber, code) {
    const forget = new FormData();
    forget.append("loginName", loginName);
    forget.append("password", password);
    forget.append("phonenumber", phonenumber);
    forget.append("code", code)
    return http.post("/api/password/forget", forget)
}
//上传图片
export function uploadAvatar(file, fileUseForEnum = "BBS") {
    const uploadImg = new FormData();
    uploadImg.append("file", file);
    uploadImg.append("fileUseForEnum", fileUseForEnum);
    return http.post("/api/nos/upload/image", uploadImg)

}
    
//登录之后查看个人信息
export function checkInfo(){
    const url =`/api/login-user/info`
    return http.get(url)
}
//退出登录
export function logOut(){
    const url = `/api/logout`
    return http.get(url)
}
//修改头像
export function changeImg(avatarfile){
    const uploadImg = new FormData();
    uploadImg.append("avatarfile",avatarfile);
    return http.post("/api/system/user/profile/update/avatar/nos",uploadImg).then(res=>{
        //debugger;
        return res;
    })
}
//修改个人信息
export function changePersonalInfo(loginName,userName,phonenumber,email,password){
    const formdata = new FormData();
    formdata.append("loginName",loginName);
    formdata.append("userName",userName);
    formdata.append("phonenumber",phonenumber);
    formdata.append("email",email);
    formdata.append("password",password);
    return http.post("/api/system/user/profile/update",formdata)
}
//我参与的
export function postArticle(){
    const formData = new FormData();
    return http.post(`/api/bbs/bbsPosts/join/list`,formData)
}
//贴子列表 搜索
export function postList(value){
    const formData = new FormData();
    formData.append("title",value);
    return http.post(`/api/bbs/bbsPosts/open/list`,formData)
}
// 推荐
export function Recommend(){
    return http.post("/api/bbs/bbsPosts/open/list")
}